import { BrowserModule } from "@angular/platform-browser";
import { NgModule, APP_INITIALIZER } from "@angular/core";

import { AppRoutingModule } from "./app-routing.module";
import { AppComponent } from "./app.component";
import { FormsModule } from "@angular/forms";
import { HttpClientModule } from "@angular/common/http";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
import { NZ_I18N } from "ng-zorro-antd/i18n";
import { zh_CN } from "ng-zorro-antd/i18n";
import { registerLocaleData } from "@angular/common";
import zh from "@angular/common/locales/zh";

registerLocaleData(zh);
export function StartupServiceFactory() {
  return () =>
    new Promise((reslove, reject) => {
      setTimeout(() => {
        reslove(true);
      }, 300);
    });
}
const APPINIT_PROVIDES = [
  {
    provide: APP_INITIALIZER,
    useFactory: StartupServiceFactory,
    multi: true,
  },
];

@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    AppRoutingModule,
    FormsModule,
    HttpClientModule,
    BrowserAnimationsModule,
  ],
  providers: [{ provide: NZ_I18N, useValue: zh_CN }, ...APPINIT_PROVIDES],
  bootstrap: [AppComponent],
})
export class AppModule {}
